package sparrowGui.item
{
	import flash.text.TextField;
	
	import sparrowGui.ComponentDraw;
	import sparrowGui.SparrowGUI;
	import sparrowGui.utils.PubFun;

	/**
	 * 带背景色的文本标签(本组件暂未使用)
	 * @author Pelephone
	 */	
	public class Label extends ComponentDraw
	{
		private var _label:TextField = new TextField();
		private var _textTag:String;
		
		public function Label(txt:String=null,vars:Object=null)
		{
//			if(!vars) vars = SparrowGUI.getInstance().labelCss;
//			_label.styleSheet = SparrowGUI.txtCss;
			
			super(vars);
			
			text = txt;
		}
		
		override protected function init():void
		{
			if(_label){
				_label.mouseEnabled = _label.selectable = false;
				addChild(_label);
			}
		}
		
		override public function set style(vars:Object):void
		{
			super.style = (vars);
			
			_label.width = vars.width - vars.paddingLeft - vars.paddingRight;
			_label.height = vars.height - vars.paddingTop - vars.paddingBottom;
			_label.x = vars.paddingLeft;
			_label.y = vars.paddingTop;
			
			_textTag = vars.textTag;
			text = text
		}
		
		override public function setSize(w:Number, h:Number):void
		{
			_label.width = w;
			_label.height = h;
			super.setSize(w,h);
		}
		
		///////////////////////////////////
		// getter/setters
		///////////////////////////////////
		
		public function get text():String
		{
			return _label.text;
		}
		
		public function set text(value:String):void
		{
			if(!_textTag)
				_label.text = value;
			else
				_label.htmlText = PubFun.setTextTag(value,_textTag);
		}
	}
}